﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ZP.Web.Admin.Job.Default" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<%--<%@ Register src="UCEdit.ascx" tagname="UCEdit" tagprefix="uc1" %>
--%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .layer {             
             width : 200px;
             padding : 5px;
             border : solid 1px silver;
             font-size:12px;
        }
        
        .layer li {
            line-height:20px;
            background-color : silver;
            padding : 1px 5px;
        }
    </style>
</head>
<body>
    <script type="text/javascript" src="../Kwan.Base.js"></script>
    <script type="text/javascript" src="Kwan.Job.js"></script>
    <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" Theme="Gray" DirectMethodNamespace="Job" />

        <ext:Store runat="server" ID="IndustryDS">
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="Code" />
                        <ext:RecordField Name="Name" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
            <SortInfo Field="Code" Direction="ASC" />
        </ext:Store>

        <ext:Store runat="server" ID="FuntypeDS">
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="Code" />
                        <ext:RecordField Name="Name" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
            <SortInfo Field="Code" Direction="ASC" />
        </ext:Store>

        <ext:Store runat="server" ID="JobareaDS">
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="Code" />
                        <ext:RecordField Name="Name" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
            <SortInfo Field="Code" Direction="ASC" />
        </ext:Store>

        <ext:Store ID="Store1" runat="server" OnRefreshData="RefreshDS" RemoteSort="True">
            <Proxy>
                <ext:PageProxy />
            </Proxy>
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="id" />
                        <ext:RecordField Name="JobName" />
                        <ext:RecordField Name="Industry" />
                        <ext:RecordField Name="Industrytype" />
                        <ext:RecordField Name="Funtype" />
                        <ext:RecordField Name="Fun" />
                        <ext:RecordField Name="Jobarea" />
                        <ext:RecordField Name="City" />
                        <ext:RecordField Name="CompanyName" />
                        <ext:RecordField Name="Scale" />
                        <ext:RecordField Name="Click" />
                        <ext:RecordField Name="Issuedate"/>
                        <ext:RecordField Name="EndDate" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
            <AutoLoadParams>
                <ext:Parameter Name="start" Value="0" Mode="Raw"/>
                <ext:Parameter Name="limit" Value="20" Mode="Raw"/>
            </AutoLoadParams>
            <SortInfo Field="EndDate,Scale" Direction="DESC" />
            <Listeners> 
                <LoadException Handler="Ext.MessageBox.alert('Load failed', response.statusText);" />                            
            </Listeners>
        </ext:Store>
        <ext:Viewport ID="Viewport1" runat="server" Layout="Fit">
            <Items>
        <ext:GridPanel ID="GridPanel1" runat="server" StoreID="Store1" Title="Employees" AutoExpandColumn="JobName" Header="False" Frame="true" Height="500">
            <ColumnModel runat="server">
			    <Columns>
                    <ext:RowNumbererColumn />
                    <ext:Column Header="职位名称" DataIndex="JobName" Width="150" />
                    <ext:Column Header="所属行业" DataIndex="Industry" Width="100" />
                    <ext:Column Header="职能类别" DataIndex="Fun" Width="100" />
                    <ext:Column Header="城市" DataIndex="City" Width="80" />
                    <ext:Column Header="所属企业" DataIndex="CompanyName" Width="150" />
                    <ext:CommandColumn Header="级别" DataIndex="Scale" Width="40">
                        <Commands>
                            <ext:GridCommand CommandName="Scale" />
                        </Commands>
                        <PrepareToolbar Fn="Kwan.prepareScaleLevel" />
                    </ext:CommandColumn>
                    <ext:Column Header="点击" DataIndex="Click" Width="50" />
                    <ext:DateColumn Header="发布日期" DataIndex="Issuedate" Width="80" Format="yyyy-MM-dd" />
                    <ext:DateColumn Header="结束日期" DataIndex="EndDate" Width="80" Format="yyyy-MM-dd" />
                    <ext:CommandColumn Width="55" Hideable="false">
                        <Commands>
                            <ext:GridCommand CommandName="Delete" Icon="Delete" Text="删除">
                                <ToolTip Text="删除该条记录" />
                            </ext:GridCommand>
                        </Commands>
                    </ext:CommandColumn>
			    </Columns>
            </ColumnModel>
            <TopBar>
                <ext:Toolbar runat="server">
                    <Items>
                        <ext:Hidden ID="txtFilter" runat="server" AutoDataBind="true">
                            <Listeners>
                                <Change Handler="Store1.reload();" Delay="30" />
                            </Listeners>
                        </ext:Hidden>
                        <ext:ComboBox ID="searchCid" runat="server" Width="300" FieldLabel="行业" LabelWidth="35" LabelAlign="Right" Editable="false" StoreID="FuntypeDS" DisplayField="Name" ValueField="Code" EmptyText="请选择..." ItemSelector="td.list-item">
                        <Template runat="server">
                                <Html>
                                    <tpl for=".">
                                        <tpl if="[xindex] == 1"><table class="txtCustomers-list"></tpl>
                                        <tpl if="[xindex - 1] % 2 == 0"><tr></tpl>
                                        <td class="list-item" align="center" width="50%" style="padding:3px;height:35px;">{Name}</td>
                                        <tpl if="[xcount-xindex]==0"></tr></table></tpl>
                                    </tpl>
                                </Html>
                            </Template>
                            <Triggers>
                                <ext:FieldTrigger Icon="Clear" HideTrigger="true" />
                            </Triggers>
                            <Listeners>
                                <BeforeQuery Handler="this.triggers[0][ this.getRawValue().toString().length == 0 ? 'hide' : 'show']();" />
                                <TriggerClick Handler="if(index == 0) { this.focus().clearValue(); trigger.hide(); #{txtFilter}.setValue(''); }" />
                                <Select Handler="Job.ShowFuntype(this.getValue(),'searchCid');" />
                            </Listeners>
                        </ext:ComboBox>
                        <ext:ToolbarSeparator runat="server" />
                        <ext:TriggerField ID="txtSearch" runat="server" EmptyText=" 全文搜索.." EnableKeyEvents="true">
                            <Listeners>
                                <KeyDown Handler="if(!Ext.isEmpty(this.getValue())) { this.triggers[0].show();}else{this.triggers[0].hide();}" />
                                <TriggerClick Handler="if (index == 1) { Store1.reload(); } if(index == 0) { this.triggers[0].hide(); }" />
                            </Listeners>
                            <Triggers>
                                <ext:FieldTrigger Icon="Clear" HideTrigger="true" />
                                <ext:FieldTrigger Icon="Search" />
                            </Triggers>
                        </ext:TriggerField>
                        <ext:ToolbarFill runat="server" />
                        <ext:Button ID="BtnAddInfo" runat="server" Text="添加" Icon="Add">
                            <DirectEvents>
                                <Click OnEvent="BtnAddInfo_Click" />
                            </DirectEvents>
                        </ext:Button>
                        <ext:Button ID="BtnDeleteInfo" runat="server" Text="批量删除" Icon="Exclamation">
                            <Listeners>
                                <Click Handler="Kwan.CheckDelete(Ext.encode(#{GridPanel1}.getRowsValues({selectedOnly:true})));" />
                            </Listeners>
                        </ext:Button>
                        <ext:ToolbarSeparator ID="ToolbarSeparator2" runat="server" />
                        <ext:Button ID="BtnChangeScale" runat="server" Text="更改级别" Icon="ArrowSwitchBlueGreen">
                            <Menu>
                                <ext:Menu ID="Menu1" runat="server">
                                    <Items>
                                        <ext:MenuItem ID="Scale_0" runat="server" Text="禁用" Icon="Decline" />
                                        <ext:MenuItem ID="Scale_1" runat="server" Text="免费" Icon="BulletTick" />
                                        <ext:MenuItem ID="Scale_2" runat="server" Text="VIP" Icon="Ruby" />
                                    </Items>
                                    <Listeners>
                                        <ItemClick Handler="Job.ChangeAllState(Ext.encode(#{GridPanel1}.getRowsValues({selectedOnly:true})),menuItem.id);" />
                                    </Listeners>
                                </ext:Menu>
                            </Menu>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:ComboBox ID="CmbFuntype" runat="server" Width="150" FieldLabel="行业" LabelWidth="35" LabelAlign="Right" Editable="false" StoreID="FuntypeDS" DisplayField="Name" ValueField="Code" EmptyText="更改职能..." ItemSelector="td.list-item">
                        <Template ID="Template1" runat="server">
                                <Html>
                                    <tpl for=".">
                                        <tpl if="[xindex] == 1"><table class="txtCustomers-list"></tpl>
                                        <tpl if="[xindex - 1] % 1 == 0"><tr></tpl>
                                        <td class="list-item" align="center" width="50%" style="padding:3px;height:35px;">{Name}</td>
                                        <tpl if="[xcount-xindex]==0"></tr></table></tpl>
                                    </tpl>
                                </Html>
                            </Template>
                            <Triggers>
                                <ext:FieldTrigger Icon="Clear" HideTrigger="true" />
                            </Triggers>
                            <Listeners>
                                <BeforeQuery Handler="this.triggers[0][ this.getRawValue().toString().length == 0 ? 'hide' : 'show']();" />
                                <TriggerClick Handler="if(index == 0) { this.focus().clearValue(); trigger.hide(); #{txtFilter}.setValue(''); }" />
                                <Select Handler="Job.ChangeFuntype(this.getValue());" />
                            </Listeners>
                        </ext:ComboBox>
                    </Items>
                </ext:Toolbar>
            </TopBar>
            <SelectionModel>
               <ext:CheckboxSelectionModel ID="CheckboxSelectionModel1" runat="server" />                   
            </SelectionModel>
            <LoadMask ShowMask="true" />
            <SaveMask ShowMask="true" />
            <BottomBar>
                <ext:PagingToolbar ID="PagingToolBar1" runat="server" PageSize="20">
                    <Items>
                        <ext:Label runat="server" Text="每页显示:" />
                        <ext:ToolbarSpacer runat="server" Width="10" />
                        <ext:ComboBox Editable="false" runat="server" Width="80">
                            <Items>
                                <ext:ListItem Text="10" />
                                <ext:ListItem Text="20" />
                                <ext:ListItem Text="50" />
                                <ext:ListItem Text="100" />
                            </Items>
                            <SelectedItem Value="20" />
                            <Listeners>
                                <Select Handler="#{PagingToolBar1}.pageSize = parseInt(this.getValue()); #{PagingToolBar1}.doLoad();" />
                            </Listeners>
                        </ext:ComboBox>
                    </Items>
                </ext:PagingToolbar>
            </BottomBar>
            <Listeners>
                <Command Handler="Kwan.CellCommand(this, record, command, rowIndex)" />
                <RowDblClick Handler="Kwan.CellCommand(this, this.store.getAt(rowIndex), 'Edit', rowIndex)" />
            </Listeners>        
        </ext:GridPanel>
        </Items>
        </ext:Viewport>
        <ext:Window ID="EditWindow" runat="server" Icon="Group" Title="编辑数据" Width="650" Height="500" AutoShow="false" Modal="false" Collapsible="true" Hidden="true" Layout="Fit" LabelWidth="70">
            <Items>
                <ext:TabPanel ID="TabPanel1" runat="server" ActiveTabIndex="0" Border="false" DeferredRender="false">
                    <Items>
                        <ext:FormPanel ID="JobForm" MonitorValid="true" runat="server" Title="基本信息" Icon="ChartOrganisation" Padding="5" Layout="Form" LabelAlign="Right" LabelWidth="70" MonitorResize="true">
                            <Items>
                                <ext:Hidden ID="txtID" runat="server" />
                                <ext:TextField ID="txtJobName" FieldLabel="职位名称" AnchorHorizontal="98%" EmptyText="请输入内容.." AllowBlank="false" runat="server" />
                                <ext:ComboBox ID="txtFuntype" Editable="false" StoreID="FuntypeDS" FieldLabel="职能类别" DisplayField="Name" ValueField="Code" EmptyText="请选择..." AnchorHorizontal="50%" AllowBlank="false" ItemSelector="td.list-item" runat="server">
                                    <Template runat="server">
                                        <Html>
                                            <tpl for=".">
                                                <tpl if="[xindex] == 1"><table class="txtCustomers-list"></tpl>
                                                <tpl if="[xindex - 1] % 2 == 0"><tr></tpl>
                                                <td class="list-item" align="center" width="20%" style="padding:3px;height:30px;">{Name}</td>
                                                <tpl if="[xcount-xindex]==0"></tr></table></tpl>
                                            </tpl>
                                        </Html>
                                    </Template>
                                    <Listeners>
                                        <Select Handler="Job.ShowFuntype(this.getValue(),'txtFuntype');" />
                                    </Listeners>
                                </ext:ComboBox>
                                <ext:ComboBox ID="txtJobarea" Editable="false" StoreID="JobareaDS" FieldLabel="工作地点" DisplayField="Name" ValueField="Code" EmptyText="请选择..." AnchorHorizontal="98%" AllowBlank="false" ItemSelector="td.list-item" runat="server">
                                    <Template runat="server">
                                        <Html>
                                            <tpl for=".">
                                                <tpl if="[xindex] == 1"><table class="txtCustomers-list"></tpl>
                                                <tpl if="[xindex - 1] % 8 == 0"><tr></tpl>
                                                <td class="list-item" align="center" width="13%" style="padding:3px;height:20px;">{Name}</td>
                                                <tpl if="[xcount-xindex]==0"></tr></table></tpl>
                                            </tpl>
                                        </Html>
                                    </Template>
                                </ext:ComboBox>
                                <ext:ComboBox ID="txtScale" runat="server" FieldLabel="级别" Editable="false" EmptyText="请选择...">
                                    <Items>
                                        <ext:ListItem Text="禁用" Value="0" />
                                        <ext:ListItem Text="免费" Value="1" />
                                        <ext:ListItem Text="VIP" Value="2" />
                                    </Items>
                                </ext:ComboBox>
                                <ext:DateField ID="txtIssuedate" FieldLabel="发布日期" AnchorHorizontal="30%" runat="server" DateFormat="yyyy-MM-dd HH:mm:ss" Vtype="daterange" EndDateField="txtEndDate" />
                                <ext:DateField ID="txtEndDate" FieldLabel="结束日期" AnchorHorizontal="30%" runat="server" DateFormat="yyyy-MM-dd HH:mm:ss" Vtype="daterange" StartDateField="txtIssuedate" />
                                <ext:HtmlEditor ID="txtDescription" FieldLabel="详细内容" AnchorHorizontal="98%" runat="server" AnchorVertical="60%" />
                            </Items>
                            <Listeners>
                                <ClientValidation Handler="#{SaveButton}.setDisabled(!valid);" />
                            </Listeners>
                        </ext:FormPanel>
                    </Items>
                </ext:TabPanel>
            </Items>
            <Buttons>
                <ext:Button ID="SaveButton" runat="server" Text="保存" Icon="Disk">
                    <DirectEvents>
                        <Click OnEvent="SaveEmployee" Failure="Ext.MessageBox.alert('出错啦！', '请不要尝试非法操作！');">
                            <EventMask Target="CustomTarget" CustomTarget="={#{EditWindow}.body}" ShowMask="True" />
                        </Click>
                    </DirectEvents>
                </ext:Button>
                <ext:Button ID="CancelButton" runat="server" Text="返回" Icon="Cancel">
                    <Listeners>
                        <Click Handler="#{EditWindow}.hide(null);" />
                    </Listeners>
                </ext:Button>
            </Buttons>
        </ext:Window>
    </form>
</body>
</html>
